<template>

  <a-modal  :maskClosable="false"
    v-if="visible"
    :width="500"
    @ok="bindXarea()"
    title="服务点绑定行政区"
    v-model="visible"
  >
<!--{{this.dataForm}}-->
    <a-form >

      <a-form-item
        label="行政区"
      >
        <XareaSelect v-model="dataForm.xareaids" style="width: 100%" mode="multiple"></XareaSelect>
      </a-form-item>
    </a-form>
  </a-modal>


</template>

<script>
  import XareaSelect from './XareaSelect'

  export default {
    inject: ['upShow'],
    components: { XareaSelect },
    data() {
      return {
        visible: false,
        dataForm: {
          id: null,
          identifier:'',
          name:'',
          xareaids: []
        },

        /*   -------弹窗--------*/
        mdl: {
          labelCol: {
            xs: { span: 24 },
            sm: { span: 5 }
          },
          wrapperCol: {
            xs: { span: 24 },
            sm: { span: 16 }
          }
        }
      }
    },
    methods: {
      init(id, row) {
        console.log('3333',row)
        this.dataForm.id = row.id
        this.dataForm.identifier = row.identifier
        this.dataForm.name = row.name
        this.dataForm.xareaids = row.xareaids ?   row.xareaids : []
        this.visible = true
      },

      bindXarea() {
        //编辑权限
        const params = {... this.dataForm}
        this.$axios
          .post(this.$URLMAP.url.servicePoint.update, params)
          .then((response) => {
            if (response.code === 200) {
              this.upShow(1, '绑定行政区成功')
              this.visible = false
              this.$emit('refreshDataList' )
            } else {
              this.upShow(2, res.msg || '绑定行政区失败')
            }
          }).catch(err => {
          this.upShow(2, '绑定行政区接口调用失败')
        })
      }
    },
    watch: {
      checkedKeys(val) {
        console.log('onCheck', val)
      }
    }
  }
</script>
